using System;
using System.Web.UI.WebControls;
using Oplaco.Core.Configuration;
using Oplaco.Core.BusinessLogicLayer;
using System.Web.Security;
using System.Web;
using System.Configuration;



public partial class Login_aspx : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //set page title for SEO
            Oplaco.Core.Configuration.SiteSettings settings = Oplaco.Core.Configuration.SiteSettings.GetSharedSettings();
            Page.Title = settings.SiteName + " | " + SiteMap.CurrentNode == null ? SiteMap.CurrentNode.Title : String.Empty;


            if (!Page.IsPostBack)
            {
                AccessNoticePanel.Visible = (Request.QueryString["ReturnUrl"] != null);
            }
            else
                AccessNoticePanel.Visible = false;

            
        }        
        catch (Exception exception)
        {
            CustomValidator val = new CustomValidator();
            val.IsValid = false;
            val.ErrorMessage = ConfigurationManager.AppSettings["GenericErrorMessage"];
            val.ValidationGroup = "LoginGroup";
            this.Page.Validators.Add(val);
            Oplaco.Exceptions.AppService.ProcessAndNotifyPresentationLayerException(exception);
        }
    }

    protected void btnClick_LoginWithTwitter(object sender, EventArgs e) {

        try
        {
            MembersDB MDB = new MembersDB();
            //MDB.ValidateUser(TwitterUserName.Text);

        }
        catch (Oplaco.Exceptions.BusinessLayerException BLE)
        {
            CustomValidator val = new CustomValidator();
            val.IsValid = false;
            val.ErrorMessage = ConfigurationManager.AppSettings["GenericErrorMessage"];
            val.ValidationGroup = "LoginGroup";
            this.Page.Validators.Add(val);
            Oplaco.Exceptions.AppService.ProcessAndNotifyPresentationLayerException(BLE);
        }
        catch (Exception exception)
        {
            CustomValidator val = new CustomValidator();
            val.IsValid = false;
            val.ErrorMessage = ConfigurationManager.AppSettings["GenericErrorMessage"];
            val.ValidationGroup = "LoginGroup";
            this.Page.Validators.Add(val);
            Oplaco.Exceptions.AppService.ProcessAndNotifyPresentationLayerException(exception);
        }
        
    }

    protected void LoginError(object sender, EventArgs e)
    {
        CustomValidator val = new CustomValidator();
        val.IsValid = false;
        val.ErrorMessage = LoginConrol.FailureText;
        val.ValidationGroup = "LoginGroup";
        this.Page.Validators.Add(val);
    }

    
}
